<template>
  <div class="menu">
    <div :class="!darkSkin ? 'main' : 'main dark'">
      <ul>
        <li>
          <router-link to="/index">首页</router-link>
        </li>
        <li>分类</li>
        <li>
          <router-link to="/archives">归档</router-link>
        </li>
        <li>
          <router-link to="/message">留言</router-link>
        </li>
        <li>日记</li>
        <li>
          <router-link to="/link">友链</router-link>
        </li>
        <li>关于</li>
      </ul>
    </div>
    <div :class="!darkSkin ? 'tool' : 'tool dark'">
      <ul>
        <li>
          <i
            class="iconfont icon-sousuotianchong"
            style="margin-left: 5px; font-size: 1.1rem"
          >
          </i>
        </li>
        <li>
          <span
            class="iconfont icon-weibiaoti-"
            v-show="skinIcon"
            @click="changeSkin"
          ></span>
          <span
            class="iconfont icon-moonyueliang"
            v-show="!skinIcon"
            @click="changeSkin"
          ></span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  name: "Menu",

  data() {
    return {
      skinIcon: true,
    };
  },
  methods: {
    changeSkin() {
      const skin = this.$store.state.darkSkin;
      this.$store.commit("changeSkin", !skin);
    },
  },
  computed: {
    darkSkin() {
      return this.$store.state.darkSkin;
    },
  },
  watch: {
    darkSkin: {
      handler: function (newVal, oldVal) {
        this.skinIcon = newVal;
      },
      immediate: true,
    },
  },
};
</script>

<style scoped>
* {
  box-sizing: border-box;
  list-style: none;
  text-decoration: none;
}
.menu {
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 80%;
  height: 55px;
}

.main {
  width: 60%;
  height: 40px;
}
.main.dark {
  background-color: #353535;
}
.main ul {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: space-around;
  align-items: center;
}
.main li {
  width: 10%;
  font-size: 1rem;
  text-align: center;
}
.main li a {
  color: #fff;
}
.main li a:hover {
  cursor: pointer;
  color: #ff9f43;
}

.main.dark li:hover {
  color: #ffffff;
  text-shadow: 0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255);
}
.tool {
  display: flex;
  flex-direction: row;
}
.tool.dark {
  background-color: #353535;
}
.tool ul {
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: space-around;
  align-items: center;
}
.tool li:hover {
  cursor: pointer;
  color: #ff9f43;
}
.tool.dark li:hover {
  color: #ffffff;
  text-shadow: 0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255),
    0 0 20px rgb(0, 208, 255), 0 0 20px rgb(0, 208, 255);
}
.tool li:nth-child(1) {
  width: 250px;
  font-size: 1.1rem;
  text-align: right;
}
.tool li:nth-child(2) {
  width: 100px;
  font-size: 1.1rem;
  text-align: center;
}
</style>